<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      /*清除空格*/
      (function () {
        let str = '   abc    ';
        console.log(str);
        console.log(str.trim()); //空格左右
        console.log(str.trimStart()); //清左
        console.log(str.trimEnd()); //清右
      })();
    </script>
  </body>
</html>
